home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
10,000 Great Games
/
10,000 Great Games.iso
/
Product
/
66
/
data1.cab
/
Source_Files
/
Src
/
Template.h
< prev
next >
Wrap
C/C++ Source or Header
|
2000-01-16
|
577b
|
48 lines
template <class T>
void swap2(T &v1, T &v2)
{
T tmp = v2;
v2 = v1;
v1 = tmp;
}
template <class T>
void sort2(T &v1, T &v2)
{
if (v2 < v1)
swap2(v1, v2);
}
template <class T>
void limit_upperbound(T &v, T upper)
{
if (v > upper)
v = upper;
}
template <class T>
void limit_lowerbound(T &v, T lower)
{
if (v < lower)
v = lower;
}
template <class T>
void safe_delete(T **p)
{
if (*p != 0)
{
delete *p;
*p = 0;
}
}
template <class T>
void safe_release(T **p)
{
if (*p != 0)
{
(*p)->Release();
*p = 0;
}
}